import json

import requests

if __name__ == "__main__":
    kw = input("enter a word:")
    # ua伪装
    headers = {
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36 Edg/97.0.1072.62"
    }
    response = requests.post(url="https://fanyi.baidu.com/sug", data={"kw": kw}, headers=headers)
    json.dump(response.json(), open("./file/" + kw + ".json", "w", encoding="utf-8"), ensure_ascii=False)
    print("over!!!")
